package com.zhejiangzhengyuan.municipal_common.controller;

import com.zhejiangzhengyuan.municipal_common.entity.Action;

import com.zhejiangzhengyuan.municipal_common.response.ResponseVo;
import com.zhejiangzhengyuan.municipal_common.service.ActionService;
import com.zhejiangzhengyuan.municipal_common.utils.ConstantUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author lin_ju
 * @create on 2019/11/22
 */
@Api(tags = "服务行为管理")
@RestController
@RequestMapping("/monitorSite")
public class MonitorSiteController {

  @Autowired private ActionService actionService;

  @PostMapping
  @ApiOperation("添加服务行为Api")
  public ResponseVo<Action> createPojo(
      @ApiParam(value = "body formData 参数", required = true) @RequestBody @Validated
          Action action) {

    return actionService.save(action)
        ? new ResponseVo<Action>(ConstantUtil.ResultCode.SUCCESS, action)
        : new ResponseVo<Action>(ConstantUtil.ResultCode.SERVER_ERROR, action);
  }
}
